package main

import (
	// "github.com/micro/go-log"
	// "github.com/micro/go-micro"
	"log"

	"github.com/go-micro/plugins/v4/server/grpc"
	"go-micro.dev/v4"

	_ "gin_miaosa/zhiliao_user_srv/data_source"
	//"zhiliao_user_srv/subscriber"
	//"zhiliao_user_srv/handler"
	//example "zhiliao_user_srv/proto/example"\

	user_front "gin_miaosa/zhiliao_user_srv/proto/user_front"

	// "github.com/micro/go-grpc"
	"gin_miaosa/zhiliao_user_srv/controller"
)

func main() {
	// New Service
	// srv := grpc.NewServer(
	// 	micro.Name("zhiliao.user.srv.zhiliao_user_srv"),
	// 	micro.Version("latest"),
	// )

	grpcServer := grpc.NewServer()

    srv := micro.NewService(
        micro.Server(grpcServer),
     	micro.Name("zhiliao.user.srv.zhiliao_user_srv"),
		micro.Version("latest"),
        micro.Address("0.0.0.0:9001"),
        // micro.RegisterTTL(time.Second*30),
        // micro.RegisterInterval(time.Second*10),
    )

	// Initialise service
	srv.Init()

	// consulReg := consul.NewRegistry()
    // // Create service
    // srv := micro.NewService(
    //     micro.Address("127.0.0.1:9000"),  //指定微服务的ip:  选择注册服务器地址,也可以不配置,默认为本机,也可以选择consul集群中的client
    //     micro.Name(service),
    //     micro.Version(version),
    //     //注册consul
    //     micro.Registry(consulReg),
    // )
    // srv.Init(
    //     micro.Name(service),
    //     micro.Version(version),
    // )

	// Register Handler
	//example.RegisterExampleHandler(service.Server(), new(handler.Example))
	user_front.RegisterFrontUserHandler(srv.Server(),new(controller.FrontUser))




	// Register Struct as Subscriber
	//micro.RegisterSubscriber("zhiliao.user.srv.zhiliao_user_srv", service.Server(), new(subscriber.Example))

	// Register Function as Subscriber
	//micro.RegisterSubscriber("zhiliao.user.srv.zhiliao_user_srv", service.Server(), subscriber.Handler)

	// Run service
	if err := srv.Run(); err != nil {
		log.Fatal(err)
	}
}
